package br.com.verde.exemploteca.underscore

object Partials {
  
  def fullFunction(a: Int, b: Int) = a + b
  
  def hasApple(fruit: String) = fruit.toLowerCase == "apple" // Prolific mode

  def main(args : Array[String]) : Unit = {
    val a = new Array[String](3)
    a(0) = "orange"
    a(1) = "apple"
    a(2) = "grape"
    
    if (a exists hasApple) println("We have an apple") // Prolific mode
    
    // underscore is as a blank that needs to be filled in.
    if (a exists (_.toLowerCase == "apple")) println("We have an apple")
    
    val partialFunction = fullFunction(1, _: Int)
    
    println(partialFunction(2))
    
    val otherFunction = fullFunction _
    
    println(otherFunction(1, 2))
    
    
  }
}

//class Array[T](l: int) extends (Int => T) {
// ...
//  def exists(p: T => Boolean)
// ...
//}
